package Work20241108;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author zdl
 * @date 2024/11/9
 */
public class Demo12 {
    public static void main(String[] args) {
        //1.用户输入的10个整数，并输出这10个整数的最大值、最小值和平均值，并按降序排序
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[10];
        for (int i = 0; i < 10; i++) {
            System.out.println("请输入第"+(i+1)+"个整数:");
            int a = sc.nextInt();
            arr[i] = a;
        }
       // int[] arr = {1,23,5,2};
        int maxIndex = 0;
        int minIndex = 0;
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[maxIndex] < arr[i]){
                maxIndex = i;
            }
            if (arr[minIndex] > arr[i]){
                minIndex = i;

            }
            sum += arr[i];
            for (int j = 0; j < arr.length-1; j++) {
                if (arr[j] > arr[j+1]){
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }

        }
        System.out.println(arr[maxIndex]); //最大值
        System.out.println(arr[minIndex]);  //最小值
        double avg = sum * 1.0 / arr.length;
        System.out.println("平均值:"+avg);
        System.out.println(Arrays.toString(arr));
    }
}
